package com.tzbank.common.controller;

import com.tzbank.common.service.PushMsgConfigService;
import com.tzbank.entity.mpass.PushMsgConfig;
import com.tzbank.utils.ResultCode;
import com.tzbank.utils.ResultUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("pushConfig")
public class PushMsgConfigController {

	@Resource
	private PushMsgConfigService pushMsgConfigService;

	@PostMapping(value = "/getByBusinessType")
	public Map<String, Object> findByBusinessType(@RequestBody Map<String, String> reqBody) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String businessType = reqBody.get("businessType");
		PushMsgConfig config = pushMsgConfigService.findByBusinessType(businessType);
		if (config != null) {
			resultMap.put("pushMsgConfig", config);
			return ResultUtil.resultMap("查询成功", ResultCode.RESULT_CODE_SUCCESS.code(), resultMap);
		}
		return ResultUtil.resultMap("参数:"+businessType+" 查询消息配置不存在", ResultCode.RESUTL_CODE_FAILURE.code(), resultMap);
	}
}
